import { defineConfig } from "vite";
import path from "path";
import vue from '@vitejs/plugin-vue'
// element-plus按需引入
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
export default defineConfig({
    plugins: [
        vue(),
        AutoImport({
            resolvers: [ElementPlusResolver()],
        }),
        Components({
            resolvers: [ElementPlusResolver()],
        }),],
    server: {
        // 设置服务启动端口号
        port: 3000,
        // 启动项目后自动打开浏览器
        open: true,
        // 允许跨域
        cors: true,
        // 打开热更新
        hmr: true
    },

    resolve: {
        // 设置别名
        alias: {
            '@': path.resolve(__dirname, 'src'),
            '@pages': path.resolve(__dirname, 'src/pages'),
            '@components': path.resolve(__dirname, 'src/components'),
            '@router': path.resolve(__dirname, 'src/router'),
            '@assets': path.resolve(__dirname, 'src/assets'),
            '@store': path.resolve(__dirname, 'src/store'),
            '@api': path.resolve(__dirname, 'src/api')
        }
    },
})